<?php 
//debug($this->data);
if(isset($this->data['UserCredit'])){
    $creditsum='0';
    foreach($this->data['UserCredit'] as $value){
        $creditsum+=$value['credit'];
    }
}

?><h2>Edit <?php echo ($this->data['User']['role']=='admin') ? "Moderator" : "User"; ?>  </h2>    
  <table id="table" width="700px" cellpadding="5" cellspacing="5">
    <tr align="center">
        <td>
            <?php echo $this->Form->Create('User'); 
            echo $this->Form->input('role',array('type'=>'hidden'));        //We are passing it to redirect to the correct page after success
            ?>
            <table cellpadding="10" cellspacing="10">
                <tr>
                    <td id="label" >Registration Date</td>
                    <td><?php echo $this->data['User']['created']; ?></td>
                </tr>                
                <tr>
                    <td id="label"  >Points</td>
                    <td><?php echo $creditsum; ?></td>
                </tr> 
                 <tr>
                    <td id="label"  >Login</td>
                    <td><?php echo $this->Form->input('User.username', array('label' => '')); ?></td>
                </tr> 
                 <tr>
                    <td id="label"  >Email</td>
                    <td><?php echo $this->Form->input('User.email', array('label' => '')); ?></td>
                </tr> 
                <tr>
                    <td id="label"  >Password</td>
                    <td><?php echo $this->Form->input('User.pass', array('label' => '','value'=>'','type'=>'password')); ?></td>
                </tr> 
                 <tr>
                    <td id="label"  >Status</td>
                    <td><?php echo $this->Form->input('User.status', array('label' => '','type'=>'checkbox')); ?></td>
                </tr> 
                <tr>
                    <td></td>
                    <td></td>
                </tr>
            </table>
<?php echo $this->Form->end(array('label'=>'Update','class'=>'mybutton')); ?>
        </td>
    </tr>
</table>


